#include "CWorkingDay.h"                //  class definition
#include <QDebug>                       //  debug helpers

//------------------------------------------
//  Constructors/Destructors and Serializers
//------------------------------------------
CWorkingDay::CWorkingDay()
{
    //  Zero variables
    m_tTotalTravel;              //  Total time spent traveling
    m_tTotalDrop;                //  Total time spent dropping catalogues
    m_tTotalCollect;             //  Total time spent collecting catalogues
    m_tTotalDelivery;            //  Total time spent delivering orders

    m_iTotalDropped = 0;                            //  Total catalogues put out
    m_iTotalCollected = 0;                          //  Total catalogues collected in
    m_iTotalDelivered = 0;                          //  Total orders delivered

    m_iTotalOrderCollected;                         //  Total orders collected
    m_fTotalOrderAmount;                            //  Total orders collected retail value

    m_dDate;                       //  The date this day represents
}

CWorkingDay::CWorkingDay( QString buff )
{
    //  qstring buffer may need to be replaced with more suitable buffer object.

    //  Zero variables
    m_tTotalTravel;              //  Total time spent traveling
    m_tTotalDrop;                //  Total time spent dropping catalogues
    m_tTotalCollect;             //  Total time spent collecting catalogues
    m_tTotalDelivery;            //  Total time spent delivering orders

    m_iTotalDropped = 0;                            //  Total catalogues put out
    m_iTotalCollected = 0;                          //  Total catalogues collected in
    m_iTotalDelivered = 0;                          //  Total orders delivered

    m_iTotalOrderCollected;                         //  Total orders collected
    m_fTotalOrderAmount;                            //  Total orders collected retail value

    m_dDate;                       //  The date this day represents

    //  Read values from string buffer
    m_tTotalTravel << buff;
    m_tTotalDrop << buff;
    m_tTotalDelivery << buff;
    m_tTotalCollect << buff;

    m_fTotalOrderAmount << buff;
    m_iTotalOrderCollected << buff;
    m_iTotalDropped << buff;
    m_iTotalDelivered << buff;
    m_iTotalCollected << buff;

    m_dDate << tbuff;
}

virtual CWorkingDay::~CWorkingDay()
{
    //  Zero variables
    m_tTotalTravel  = QTime::NullTime;              //  Total time spent traveling
    m_tTotalDrop  = QTime::NullTime;                //  Total time spent dropping catalogues
    m_tTotalCollect  = QTime::NullTime;             //  Total time spent collecting catalogues
    m_tTotalDelivery  = QTime::NullTime;            //  Total time spent delivering orders

    m_iTotalDropped = 0;                            //  Total catalogues put out
    m_iTotalCollected = 0;                          //  Total catalogues collected in
    m_iTotalDelivered = 0;                          //  Total orders delivered

    m_iTotalOrderCollected;                         //  Total orders collected
    m_iTotalOrderAmount;                            //  Total orders collected retail value

    m_dDate= QDate::nullJd();                       //  The date this day represents
}

QString     CWorkingDay::Serialize()
{
    QString tbuff;

    //  Add date to buffer
    tbuff << m_dDate;

    //  Add totals to buffer
    tbuff << m_iTotalCollected << m_iTotalDelivered << m_iTotalDropped << m_iTotalOrderCollected;
    tbuff << m_fTotalOrderAmount;

    //  Add times to buffer
    tbuff << m_tTotalCollect << m_tTotalDelivery << m_tTotalDrop << m_tTotalTravel;

    return tbuff;
}


//------------------------------
//  Get private member variables
//------------------------------
QTime       CWorkingDay::GetTravelTime()
{
    return m_tTotalTravel;
}

QTime       CWorkingDay::GetDropTime()
{
    return m_tTotalDrop;
}

QTime       CWorkingDay::GetInTime()
{
    return m_tTotalCollect;
}

QTime       CWorkingDay::GetDeliveryTime()
{
    return m_tTotalDelivery;
}

int         CWorkingDay::GetTotalDropped()
{
    return m_iTotalDropped;
}

int         CWorkingDay::GetTotalCollected()
{
    return m_iTotalCollected;
}

int         CWorkingDay::GetTotalDelivered()
{
    return m_iTotalDelivered;
}

int         CWorkingDay::GetTotalOrdersCollected()
{
    return m_iTotalOrderCollected;
}

int         CWorkingDay::GetTotalOrdersRetailAmount()
{
    return m_iTotalOrderAmount;
}

QDate       CWorkingDay::GetDate()
{
    return m_dDate;
}
